package jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCDemo4 {
    public static void main(String[] args) throws SQLException {
        try (Connection connection = DBUtil.getConnection()) {
            Statement satatement = connection.createStatement();
            String sql = "select id,name,salary,title " +
                    "from teacher";
            ResultSet resultSet = satatement.executeQuery(sql);
            while (resultSet.next()){
                int id = resultSet.getInt("id");
                String name = resultSet.getString("name");
                double salary = resultSet.getDouble("salary");
                String title = resultSet.getString("title");
                System.out.println(id+" "+name+" "+salary+" "+title);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }


    }
}
